﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CSharpHomework6_2
{
    public partial class Form1 : Form
    {

        public static AllOrder a = AllOrder.getInstance();
        BindingSource bindingSource=new BindingSource();
        public Form1()
        {
            InitializeComponent();
            
            List<OrderItem> list = new List<OrderItem>();
            
            list.Add(new OrderItem("egg", 10, 2));
            list.Add(new OrderItem("banana", 20, 10));

            a.addOrder(2020, "dva", "2020/01/02", list);


            bindingSource.DataSource = a.order;
            table.DataSource = bindingSource;


            
           


        }

        


 
    
        private void table_Load(object sender, DataGridViewCellEventArgs e)
        {
           
            
        }

        private void createbtn_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();
            form2.a = Form1.a;
            form2.ShowDialog();
        }

        private void table_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

     

        private void deletebtn_Click(object sender, EventArgs e)
        {
            Form3 form3 = new Form3();
            form3.ShowDialog();
        }

        private void alterbtn_Click(object sender, EventArgs e)
        {
            Form3 form3 = new Form3();
            form3.ShowDialog();
        }

        private void exportbtn_Click(object sender, EventArgs e)
        {
            a.export();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //a = AllOrder.getInstance();
            //bindingSource.DataSource = a.order;
            //table.DataSource = bindingSource;
            bindingSource.ResetBindings(true);
        }

        private void searchbtn_Click(object sender, EventArgs e)
        {
            Form4 form4 = new Form4();
            form4.ShowDialog();
        }

        private void importbtn_Click(object sender, EventArgs e)
        {
            a.import();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}
